{% extends 'base.html' %}

{% block title %}{% if user.id %}编辑{% else %}新建{% endif %}用户 - 项目管理系统{% endblock %}

{% block content %}
<h2>{% if user.id %}编辑用户{% else %}新建用户{% endif %}</h2>
<a href="{{ url_for('user_list') }}" class="button button-secondary">返回列表</a>

<form method="post" style="max-width: 500px;">
    <div class="form-group">
        <label for="username">用户名 <span style="color: red;">*</span></label>
        <input type="text" id="username" name="username" value="{{ user.username }}" required>
    </div>
    
    <div class="form-group">
        <label for="password">密码 {% if not user.id %}<span style="color: red;">*</span>{% endif %}</label>
        <input type="password" id="password" name="password" {% if not user.id %}required{% endif %}>
        {% if user.id %}<small>如不修改密码，请留空</small>{% endif %}
    </div>
    
    <div class="form-group">
        <label for="real_name">真实姓名</label>
        <input type="text" id="real_name" name="real_name" value="{{ user.real_name }}">
    </div>
    
    <div class="form-group">
        <label for="email">邮箱</label>
        <input type="email" id="email" name="email" value="{{ user.email }}">
    </div>
    
    <div class="form-group">
        <label for="phone">电话</label>
        <input type="text" id="phone" name="phone" value="{{ user.phone }}">
    </div>
    
    <div class="form-group">
        <label for="status">状态</label>
        <select id="status" name="status">
            <option value="1" {% if user.status == 1 %}selected{% endif %}>活跃</option>
            <option value="0" {% if user.status == 0 %}selected{% endif %}>禁用</option>
        </select>
    </div>
    
    <button type="submit">保存</button>
</form>
{% endblock %} 